package com.sicau.service.serviceImpl;

import com.sicau.dao.UserMapper;
import com.sicau.entity.User;
import com.sicau.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by wzw on 2018/11/3
 */
@Service
public class LoginServiceImpl implements LoginService{
    @Autowired
    private UserMapper userMapper;
    @Override
    public String login(String account,String password) {
        // TODO Auto-generated method stub
        User user = userMapper.selectByAccount(account);
        if(user == null) {
            return "error";
        }else {
            if(user.getPassword().equals(password)) {
                return "welcome";
            }else {
                return "error";
            }
        }
    }

    @Override
    public int insert(User user) {
        int ret = userMapper.insert(user);
        return ret;
    }

    @Override
    public User select(String uid) {
        User user = userMapper.selectByPrimaryKey(uid);
        return user;
    }
}
